package com.ds.lens.data.common.query.es;


import java.io.IOException;

public class DateHistogramFunction implements TranslateFunction {
    public static final String NAME = "date_histogram";
    private static final String FIELD_PREFIX = "'field'=";
    private static final String INTERVAL_PREFIX = "'interval'=";
    private static final String FORMAT_FIELD = "'format'='epoch_millis'";


    @Override
    public void apply(Appendable appender, String... input) throws IOException {
        appender.append(NAME)
                .append("(")
                .append(FIELD_PREFIX)
                .append(input[0])
                .append(",")
                .append(INTERVAL_PREFIX)
                .append(input[1])
                .append(",")
                .append(FORMAT_FIELD)
                .append(")");
    }
}
